//
//  ClassificationViewController.m
//  MarryMe
//
//  Created by lanou3g on 16/1/5.
//  Copyright © 2016年 revocher. All rights reserved.
//

#import "ClassificationViewController.h"
#import "FuwuTableViewCell.h"
#import "PhotoTableViewCell.h"
#import "CaigouTableViewCell.h"
#import "ReimenTableViewCell.h"
@interface ClassificationViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *mainTableView;
@property(nonatomic,strong)UISearchBar *searchBar;
@property(nonatomic,strong)UIView *mainView;
@end

@implementation ClassificationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.mainTableView.delegate = self;
    self.mainTableView.dataSource = self;
    
    
    self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(10, 5, 350, 40)];
    [self.searchBar setPlaceholder:@"输入商家套餐话题"];
    [self.searchBar setBarStyle:UIBarStyleDefault];
    
    self.mainView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)];
    [self.mainView addSubview:self.searchBar];
    
    //cell如果是xib文件,使用以下方式去注册
    [self.mainTableView registerNib:[UINib nibWithNibName:@"FuwuTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"FuwuTableViewCell"];
    
    [self.mainTableView registerNib:[UINib nibWithNibName:@"CaigouTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"CaigouTableViewCell"];
    
    [self.mainTableView registerNib:[UINib nibWithNibName:@"ReimenTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"ReimenTableViewCell"];
    
     [self.mainTableView registerNib:[UINib nibWithNibName:@"PhotoTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"PhotoTableViewCell"];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        FuwuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FuwuTableViewCell"];
        return cell;
        
    }
    if (indexPath.row == 1) {
        PhotoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PhotoTableViewCell"];
        return cell;
    }
    if (indexPath.row == 2) {
        CaigouTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CaigouTableViewCell"];
        return cell;
    }
    if (indexPath.row == 3) {
        ReimenTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReimenTableViewCell"];
        return cell;
    }
    
    return nil;

}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return 350;
    }
    if (indexPath.row == 1) {
        return 100;
    }
    if (indexPath.row == 2) {
        return 250;
    }
    if (indexPath.row == 3) {
        return 200;
    }
    
    return 0;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
